<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Untitled Page</title>
	<script type="text/javascript">

function InsertHtml()
{
	// Get the current selection.
	var oSel = window.getSelection() ;

	// Get the first available range.
	var oRange = oSel.getRangeAt(0) ;

	// Create a fragment with the input HTML.
	var oFragment = oRange.createContextualFragment( '- This is a <b>test</b> -' ) ;

	oRange.insertNode(oFragment) ;
}
	</script>
</head>
<body>
	<p>
		This is some text. Select some text and click the following button to insert HTML on it.
	</p>
	<p>
		<input type="button" value="Insert HTML" onclick="InsertHtml();" />
	</p>
</body>
</html>
